<template>
  <div class="srbd">
    <div class="bd">
      <div class="cesaun_container">
        <h3 class="title">
          <p class="line">生肖配对</p>
        </h3>
        <div>
          <div>
            <el-form :model="form" ref="form" label-width="120px">
              <!-- 姓名 -->
              <el-form-item label="男方血型" prop="name">
                <el-select
                  v-model="form.xuexing_male"
                  clearable
                  style="width: 450px"
                >
                  <el-option
                    v-for="item in xuexing"
                    :key="item.value"
                    :label="item.name"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="女方血型" prop="name">
                <el-select
                  v-model="form.xuexing_female"
                  clearable
                  style="width: 450px"
                >
                  <el-option
                    v-for="item in xuexing"
                    :key="item.value"
                    :label="item.name"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="语言：" prop="lang">
                <el-radio-group v-model="form.lang">
                  <el-radio label="zh-cn">中文</el-radio>
                  <el-radio label="en-us">英文</el-radio>
                  <el-radio label="zh-tw">繁体</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div style="text-align: center">
          <el-button type="primary" @click="submitForm" style="margin: 20px"
            >立即测算</el-button
          >
        </div>

        <!-- 主体表单 -->
      </div>
      <div>
        <h3 class="title">
          <p class="line">测算简介</p>
        </h3>
        <div style="font-size: 14px; margin: 0 10px 20px 10px">
          <p style="">
            血型配对，不同的血型的人碰到一起，会有不一样的效果，什么样的血型配对才是最幸福的呢，可以用缘份居血型配对测测看。
          </p>

          <p>3.心诚则灵，测算结果仅供参考。</p>
        </div>
      </div>
    </div>
    <el-dialog
      title="测算结果"
      :visible.sync="centerDialogVisible"
      width="50%"
      class="dialog_cesuan"
    >
      <div class="bazi_info" v-if="result != null">
        <div class="base_info">
          <div class="show">
            <span class="l">男方血型:</span>
            <span class="r">{{ result.xuexing_male }}</span>
          </div>
          <div class="show">
            <span class="l">女方血型:</span>
            <span class="r">{{ result.xuexing_female }}</span>
          </div>

          <div class="show">
            <span class="l">结果评述:</span>
            <span class="r">{{ result.description.title }}</span>
          </div>

          <div class="show">
            <span class="l">结果详解:</span>
            <span class="r">{{ result.description.description }}</span>
          </div>
        </div>

        <div class="yl">
          <span>仅供娱乐！请勿当真</span>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  computed: {
    currentPath() {
      return this.$route.path; // 获取当前路由路径
    },
  },
  data() {
    return {
      centerDialogVisible: false,
      birthday: "",

      xuexing: [
        { name: "AB", value: "AB" },
        { name: "A", value: "A" },
        { name: "B", value: "B" },
        { name: "O", value: "O" },
      ],

      result: {
        description: {
          title: "一不如意便会冲突",
          description:
            "A型人和B型人虽然在思想方法、对周围事物的反应、以及行为方式等方面有很大差异，但他们很容易结成好朋友。这一点也说明不同于自己的人和事物对人们具有吸引力。A型人和B型人特别谈得拢；互不相同的思维和表达方式在交谈时成了很好的刺激因素。对A型来说，如对方是O型，A型常常处于接受者，而与B型相处时，会变得能言善辩起来，因为对A型来说这也是最好的解闷方式。B型人本来就以健谈见著，他们若与A型同伴在一起，那就更有话题不绝之感——这是一对最适宜交谈的朋友。可是，A型同B型若一起工作或生活的话，他们之间立刻会在行动方针、对外措施和事物的处置方法等方面发生摩擦和冲突。首先红脸的往往是办事刻板的A型。加上他们看不惯B型不拘小节的性格，一想起来就耐不住要生气。A型同B型若单从协作的作用上来看，他们可以有多种形式的结合。可以在广泛的领域里互相合作，相得益彰，成为强有力的组合。因此，对这一组合来说，了解自己与对方间的血型和气质差别最为重要。A型人对B型人的言行不要戚戚于心，斤斤计较；B型应尽可能朝A型所希望的方向努力。另外，将两者的职责范围划分清楚也是一个有效的办法。因为比较起来，A型人善于爱护，器重对方。",
        },
        xuexing_male: "A",
        xuexing_female: "B",
      },
      area: "",
      form: {
        xuexing_female: "",
        xuexing_male: "",
        lang: "zh-cn",
      },
    };
  },
  mounted() {},
  methods: {
    submitForm() {
      if (this.form.xuexing_male == "") {
        this.$message({
          message: "请输入男方血型",
          type: "warning",
        });
        return;
      }
      if (this.form.xuexing_female == "") {
        this.$message({
          message: "请输入女方血型",
          type: "warning",
        });
        return;
      }

      this.form["api_key"] = "FNcQHQuf0W8wDrXMjWc0xqTzw";
      let config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      };
      this.$axios
        .post(window.config.apiUrl + "/v1/Peidui/xuexing", this.form, config)
        .then((res) => {
          if (res.data.errcode == -1) {
            this.$message({
              type: "warning",
              message: res.data.errmsg,
            });

            return;
          }

          this.centerDialogVisible = true;
          this.result = res.data.data;
          console.log(this.result);
        });
    },
  },
};
</script>

<style scoped lang="scss">
.bd {
  border: 1px solid #e5e5e5;
}

.cesaun_container {
}

::v-deep .el-card.is-always-shadow {
  box-shadow: none !important;
}

::v-deep .el-card__header {
  padding: 10px 20px !important;
}

.form-card {
  width: 100%;
  margin: 0 auto;
  border-radius: 2px;
}

.form-title {
  margin: 0;
  color: #303133;
  font-size: 16px;
  text-align: left;
}

.el-form-item {
  margin-bottom: 22px;
}

.el-radio {
  margin-right: 30px;
}

::v-deep .distpicker-address-wrapper {
  width: 100% !important;
}

@mixin flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  height: 45px;
}

@mixin tr1_w {
  width: 33px;
  text-align: center;
}

.dialog_cesuan {
  text {
    user-select: all;
  }

  .bazi_info {
    .base_info {
      margin: 20px;

      .title {
        display: flex;
        padding: 5px;

        .shu {
          width: 5px;
          height: 20px;
          background-color: #e6a84b;
          border-radius: 10px;
        }

        .ti {
          padding-left: 8px;
          font-weight: 800;
          font-size: 15px;
        }
      }

      .show {
        margin-top: 15px;

        .l_ {
          font-size: 14px;
          display: inline-block;
          min-width: 50px;
          font-weight: 800;
        }

        .l {
          font-size: 15px;
          display: inline-block;
          min-width: 80px;
          font-weight: 800;
        }
      }

      .details {
        border: 1px solid #e5e5e5;
        border-bottom: none;
        margin-top: 20px;

        .names {
          text-align: center;
          color: #e6a84b;
          border-bottom: 1px solid #e5e5e5;
          color: #e6a84b;
          font-weight: 800;
          background-color: #fff3ef;
          height: 50px;
          line-height: 50px;
        }

        .des {
          border-bottom: 1px solid #e5e5e5;
          padding-left: 10px;
          display: flex;
          align-items: center;

          .des_text {
            color: #e6a84b;
            width: 14%;
            font-weight: 800;
            user-select: text;
          }

          .des_deta {
            width: 85%;
            line-height: 26px;
            text-indent: 2em;
            user-select: text;
          }
        }
      }
    }
  }
}
</style>